<template>
  <el-form-item label="购买的数量">
    <el-input v-model="form2.num" style="width: 600px" type="number"></el-input>
  </el-form-item>
  <el-form-item label="优惠类型">
    <el-radio :label="1" v-model="form2.type">折扣</el-radio>
    <el-radio :label="2" v-model="form2.type">固定金额</el-radio>
  </el-form-item>
  <el-form-item label="折扣" v-if="form2.type == 1">
    <el-input
      v-model="form2.discount"
      style="width: 600px"
      type="number"
      placeholder="例如：7折填写  7"
    ></el-input>
    折
  </el-form-item>
  <el-form-item label="优惠金额" v-if="form2.type == 2">
    <el-input
      v-model="form2.amount"
      style="width: 600px"
      type="number"
    ></el-input>
    元
  </el-form-item>
</template>
  
  <script>
// 聚划算、折扣
export default {
  props: {
    form: {
      type: Object,
    },
  },
  name: "Discount",
  data() {
    return {
      form2: this.form,
    };
  },
  watch: {
    form2: {
      handler(newVal) {
        this.$emit("updateComponet", { type: "discount", value: newVal });
      },
      deep: true,
    },
  },
};
</script>